<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div>
			<button>全选</button>
			<button>取消全选</button>
			<button>反选</button><br />
			<input type="checkbox"  />琴<br />
			<input type="checkbox"  />棋<br />
			<input type="checkbox"  />书<br />
			<input type="checkbox"  />画<br />
			<input type="checkbox"  />诗<br />
			<input type="checkbox"  />词<br />
			<input type="checkbox"  />歌<br />
			<input type="checkbox"  />赋
		</div>
		 <script type="text/javascript">
		 	var Btn = document.getElementsByTagName('button');
		 	var arrNpt = document.getElementsByTagName('input');
		 	Btn[0].onclick = function(){
		 	for (var i = 0; i < arrNpt.length; i++) {
		 			arrNpt[i].checked = true;
		 		}
		 	}
		 	Btn[1].onclick = function(){
		 	for (var i = 0; i < arrNpt.length; i++) {
		 			arrNpt[i].checked = false;
		 		}
		 	}
		 	Btn[2].onclick = function(){
		 	for (var i = 0; i < arrNpt.length; i++) {
		 			if (arrNpt[i].checked) {
		 				arrNpt[i].checked = false;
		 			} else{
		 				arrNpt[i].checked = true;
		 			}
		 		}
		 	}
		 </script>
	</body>
</html>
